<!-- S search -->
<app-search-bar
  [submitLoading]="tableParams.loading"
  [searchOptions]="searchOptions"
  labelFlex="80px"
  (onSearch)="queryData($event)"
  (onReset)="resetData($event)"
>
</app-search-bar>
<!-- E search -->

<nz-card class="m-t-2">
  <div class="opera-wrap">
    <button
      nz-button
      nzType="primary"
      [nzLoading]="exportLoading"
      (click)="exportTable()"
    >导出</button>
  </div>

  <div class="pagination-wrap-position p-t-10">
    <nz-table
      #basicTable
      nzSize="small"
      nzShowSizeChanger
      nzShowQuickJumper
      nzOuterBordered
      [nzScroll]="{ x: '1100px' }"
      [nzFrontPagination]="false"
      [nzLoadingDelay]="100"
      [nzLoading]="tableParams.loading"
      [nzData]="tableParams.tableData"
      [nzPageSizeOptions]="[5, 10, 20, 50, 100]"
      [nzTotal]="tableParams.total"
      [nzPageIndex]="tableParams.page"
      [nzPageSize]="tableParams.pageSize"
      [nzShowTotal]="totalTemplate"
      (nzPageIndexChange)="onPageIndexChange($event)"
      (nzPageSizeChange)="onPageSizeChange($event)"
    >
      <thead>
        <tr>
          <th nzAlign="center" nzWidth="120px" nzLeft>ID</th>
          <th nzAlign="center">收支类型</th>
          <th nzAlign="center">二级分类</th>
          <th nzAlign="center">发生时间</th>
          <th nzAlign="center">余额明细</th>
          <th nzAlign="center">关联单号</th>
          <th nzAlign="center">交易流水</th>
          <th nzAlign="center">收益到账时间</th>
        </tr>
      </thead>

      <tbody>
        <tr *ngFor="let data of basicTable.data; let index = index;">
          <!-- ID -->
          <td nzAlign="center" nzLeft>{{ data.id }}</td>
          <!-- 收支类型 -->
          <td nzAlign="center">
            <span [ngSwitch]="data.changeType">
              <!-- 收入 -->
              <p *ngSwitchCase="1">
                {{ filterText(collectBranchOptions, data.transactionType, 'content') }}
              </p>
              <!-- 提现 -->
              <p *ngSwitchCase="2">提现</p>
              <p *ngSwitchDefault>-</p>
            </span>
          </td>
          <!-- 二级分类 -->
          <td nzAlign="center">{{ data.appName || '-' }}</td>
          <!-- 发生时间 -->
          <td nzAlign="center">{{ data.createTime || '-' }}</td>
          <!-- 余额明细 -->
          <td nzAlign="center">
            <span [ngClass]="{'color-red': data.changeType == 2, 'color-green': data.changeType != 2}">
              {{ data.changeType == 2 ? ('-' + (data.amount | number : '0.2-2')) : ('+' + (data.amount | number : '0.2-2')) }}
            </span>
          </td>
          <!-- 关联单号 -->
          <td nzAlign="center">
            {{ data.businessNo || '-' }}
          </td>
          <!-- 交易流水 -->
          <td nzAlign="center">
            {{ (data.billNo && data.billNo != 0) ? data.billNo : '-' }}
          </td>
          <!-- 收益到账时间 -->
          <td nzAlign="center">{{ data.accountTime || '-' }}</td>
        </tr>
      </tbody>
    </nz-table>

    <!-- 分页template -->
    <ng-template #totalTemplate let-total>共有 {{ total }} 条</ng-template>
  </div>
</nz-card>